from datetime import date

from app01.models import Reporter, Article

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "py_django.settings")


r = Reporter(first_name='John', last_name='Smith', email='john@example.com')
r.save()
r2 = Reporter(first_name='Paul', last_name='Jones', email='paul@example.com')
r2.save()

r3 = Reporter(first_name='John', last_name='Smith', email='john@example.com')
a1 = Article(headline="This is a test", pub_date=date(2005, 7, 27), reporter=r3)

a = Article(id=None, headline="This is a test", pub_date=date(2005, 7, 27), reporter=r)
a.save()

print a.reporter.id
new_article = r.article_set.create(headline="John's second story", pub_date=date(2005, 7, 29))

print  new_article.reporter
